package logic

import (
	"1-8zy/rpc/shop"
	"context"

	"1-8zy/api/internal/svc"
	"1-8zy/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateGoodStatusLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateGoodStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateGoodStatusLogic {
	return &UpdateGoodStatusLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateGoodStatusLogic) UpdateGoodStatus(req *types.UpdateGoodStatusRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	status, err := l.svcCtx.ShopRpc.UpdateGoodStatus(l.ctx, &shop.UpdateGoodStatusRequest{
		GoodId: int64(req.GoodId),
		Status: int64(req.Status),
	})
	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}

	return &types.Response{
		Msg:  "展示成功",
		Code: 200,
		Data: status,
	}, nil
}
